#ifndef GS_IVALUE_H
#define GS_IVALUE_H

namespace Gs
{
	class IContext;
	class IString;
	class IObject;

	// Defines the native function callback type.
	typedef int (* NativeFunction)(IContext *context);

	// Defines the user pointer type.
	typedef void *UserPointer;

	// Specifies the type of a value.
	enum ValueType
	{
		NilType = 0x0,
		IntegerType = 0x1,
		FloatType = 0x2,
		StringType = 0x4,
		ObjectType = 0x8,
		FunctionType = 0x10,
		PointerType = 0x20,
		ManagedType = StringType | ObjectType | FunctionType
	};

	// Gets the type name of a specified type.
	GS_EXPIMP const char *GetValueTypeName(ValueType type);

	// Represents a GorillaScript value of any type.
	// This pointer will dangle upon reallocations of the stack.
	class GS_EXPIMP IValue
	{
	public:
		// Gets the type of the value.
		virtual ValueType GetType() const = 0;

		// Gets the type name of the value's type.
		virtual const char *GetTypeName() const = 0;

		// Gets the value as an integer, converting if necessary.
		virtual int ToInt() const = 0;

		// Gets the value as a float, converting if necessary.
		virtual float ToFloat() const = 0;

		// Gets the value as a string, converting if necessary.
		virtual IString *ToString(IContext *context) const = 0;

		// Gets the value as an object.
		virtual IObject *ToObject() const = 0;

		// Gets the value as a user pointer.
		virtual UserPointer ToUserPointer() const = 0;

		// Gets the value as a native function.
		virtual NativeFunction ToNativeFunction() const = 0;
	};
}

#endif